import com.hivekion.DemoApplication;
import com.hivekion.system.domain.vo.SysUserCreateInputVo;
import com.hivekion.system.service.ISysUserService;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.test.context.junit4.SpringRunner;

import javax.annotation.Resource;

@RunWith(SpringRunner.class)
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT,classes = DemoApplication.class)
public class InitAdminUser {

    @Resource
    private ISysUserService userService;

    @Test
    public void create() {
        SysUserCreateInputVo vo = new SysUserCreateInputVo();
        vo.setEmail("admin@admin.com");
        vo.setPhoneNumber("");
        vo.setSex(1);
        vo.setNickName("管理员");
        vo.setStatus(0);
        vo.setUserName("admin");
        if (!userService.checkPhoneUnique(vo.getPhoneNumber(), "") || !userService.checkEmailUnique(vo.getEmail(), "") || !userService.checkUserNameUnique(vo.getUserName(), "")) {
            System.out.println("已经存在！！！！！");
        } else {
            userService.create(vo);
        }
    }
}
